{extend name="admin@public:base" /}

{block name="header"}
<link rel="stylesheet" type="text/css" href="__STATIC__/multi-select/css/multi-select.css"/>
{/block}
{block name="footer"}
<script src="__STATIC__/multi-select/js/jquery.multi-select.js"></script>
<script type="text/javascript">   
    $(function(){
        //动态选择框，上下级选中状态变化
       $('input.checkbox-parent').on('change', function () {
           var dataid = $(this).attr("dataid");
           $('input[dataid^=' + dataid + '-]').prop('checked', $(this).is(':checked'));
       });

       $('input.checkbox-child').on('change', function () {
            var dataid = $(this).attr("dataid");
            dataid = dataid.substring(0, dataid.lastIndexOf("-"));
            var parent = $('input[dataid=' + dataid + ']');
            if ($(this).is(':checked')) {
                parent.prop('checked', true);
                //循环到顶级
                while (dataid.lastIndexOf("-") > 2) {
                    dataid = dataid.substring(0, dataid.lastIndexOf("-"));                      
                    parent = $('input[dataid=' + dataid + ']');
                    parent.prop('checked', true);                        

                }
            } else {
                //父级
                if ($('input[dataid^=' + dataid + '-]:checked').length == 0) {
                    parent.prop('checked', false);
                    //循环到顶级
                    while (dataid.lastIndexOf("-") > 2) {
                        dataid = dataid.substring(0, dataid.lastIndexOf("-"));
                        parent = $('input[dataid=' + dataid + ']');
                        if ($('input[dataid^=' + dataid + '-]:checked').length == 0) {
                            parent.prop('checked', false);
                        }
                    }
                }
            }
       })

    })
</script>
{/block}

{block name="content_body"}
	<div class="block-header">
		<h5>组修改</h5>
	</div>		
    <form class="form-horizontal  ajaxForm3"  method="POST">            
            <div class="card">
                <div class="body">
                     <label for="groupid">组名：</label>
                     <input type="input" id="title" name="title" class="filled-in chk-col-red" value="{$group['title']|default=''}"/>

                     <input type="hidden" name="groupid" value="{$gorup['groupid']|default=''}" />

                </div>
            </div>
            <div class="block-header">
                <h5>平台</h5>
            </div> 
            <div class="card">
                <div class="body">
                   <ul class="list-group ">
                         <li class="list-group-item list-group-bg-blue-grey">
                             <input type="checkbox" id="md_checkbox_platforms" class="filled-in chk-col-red checkbox-parent" dataid="platforms"/>
                             <label for="md_checkbox_platforms">支持的平台</label>                          
                         </li>

                         {foreach $platforms as $key=>$vo}
                            <li class="list-group-item">
                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" id="md_platform_{$key}" class="filled-in chk-col-red checkbox-child"  name="platforms[]" {eq name="vo['check']|default='0'" value="1"}checked="checked"{/eq} value="{$vo['platform']}" dataid="platforms-{$key}"/>
                                <label for="md_platform_{$key}">{$vo['title']}</label>
                            </li>  
                         {/foreach}                        
   
                      </ul>

                </div>
            </div>

            <div class="block-header">
                <h5>总服权限</h5>
            </div>      

            {foreach $center_menus as $key=>$menu}
                <div class="card col-md-2">
                    <div class="body"> 
                        <ul class="list-group">
                           <li class="list-group-item list-group-bg-blue-grey">
                               <input type="checkbox" id="md_checkbox_center_{$key}" class="filled-in chk-col-red checkbox-parent"  value="{$key}" dataid="center-menu-{$key}" />
                               <label for="md_checkbox_center_{$key}">{$menu['title']}</label>                          
                           </li>

                            {foreach $menu['_child'] as $sub_key=>$sub_menu}
                                <li class="list-group-item">
                                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" id="md_sub_checkbox_{$sub_key}" class="filled-in chk-col-red checkbox-child" dataid="center-menu-{$key}-{$sub_key}" name="rules[]" value="{$sub_key}"
                                    {in name="sub_key" value="$group['rules']|default=''"}checked="true"{/in}
                                    />
                                    <label for="md_sub_checkbox_{$sub_key}">{$sub_menu['title']} </label>
                                </li>  
                            {/foreach}

                    </div>
                </div>
            {/foreach}
    
            <div class="clearfix"></div>
            <div class="block-header clearfix">
                <h5>游戏服权限</h5>
            </div>      
            {foreach $game_menus as $key=>$menu}
                <div class="card col-md-2">
                    <div class="body"> 
                        <ul class="list-group ">
                           <li class="list-group-item list-group-bg-blue-grey">
                               <input type="checkbox" id="md_checkbox_game_{$key}" class="filled-in chk-col-red checkbox-parent" dataid="game-menu-{$key}"/>
                               <label for="md_checkbox_game_{$key}">{$menu['title']}</label>                          
                           </li>

                            {foreach $menu['_child'] as $sub_key=>$sub_menu}
                                <li class="list-group-item">
                                    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" id="md_sub_checkbox_{$sub_key}" class="filled-in chk-col-red checkbox-child" 
                                    dataid="game-menu-{$key}-{$sub_key}" name="rules[]" value="{$sub_key}"
                                    {in name="sub_key" value="$group['rules']|default=''"}checked="true"{/in}
                                    />
                                    <label for="md_sub_checkbox_{$sub_key}">{$sub_menu['title']}</label>
                                </li>  
                            {/foreach}

                    </div>
                </div>
            {/foreach}
             
              <div class="card col-md-12">
                <div class="body">      
                     
                 <input type="submit" value="确定修改"/>
       
                </div>
            </div> 
            


    </form>
                        

{/block}

